import Vue from 'vue'
import Vuex from 'vuex'
import request from '../static/js/request.js'
import api from '../static/js/api.js'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		userInfo: {},
	},
	mutations: {
		setUserInfo(state, userInfo) {
			state.userInfo = userInfo;
		},
	},
	getters: {
		// getUserInfo(state) {
		// 	return state.userInfo;
		// }
	},
	actions: {
		//获取用户信息
		async getUserInfo({
			commit,
			state
		}) {
			let userInfo = JSON.parse(uni.getStorageSync('userInfo'));
			let res = await api.read("res.partner", userInfo.partner_id,
				'id,name,idcard,account_type,mobile,age,team_id,location_company_id');

			commit('setUserInfo', res[0]);
		},
	}
})

export default store
